﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using LogosoftSharepoint.Data_Sources;

namespace LogosoftSharepoint.WebServices
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    [System.Web.Script.Services.ScriptService]
    public class TasksListService : System.Web.Services.WebService
    {
        /* Utrzymwanie sesji mozna wylaczyc, jesli nie przeszkadza nam, ze zwrocimy
         * lise taskow, osobie niezalogowanej (nieodpowiedniej)
         */
        [WebMethod(EnableSession = true)]
        public System.Linq.IQueryable<LogosoftSharepoint.Data_Sources.ls_zadania> GetListOfTasks()
        {
            if (Session["loggedin"] == null)
            {
                return null;
            }
            /* **** LINQ version **** */
            SharepointSystemDataContext ssdc = new SharepointSystemDataContext();
            var tasks = from t in ssdc.ls_zadania select t;
            return tasks;
        }
    }
}
